<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get entry object from the RAR archive</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="rararchive.getentries.html">RarArchive::getEntries</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="rararchive.isbroken.html">RarArchive::isBroken</a></div>
 <div class="up"><a href="class.rararchive.html">RarArchive</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="rararchive.getentry" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">RarArchive::getEntry</h1>
  <h1 class="refname">rar_entry_get</h1>
  <p class="verinfo">(PECL rar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">RarArchive::getEntry</span> -- <span class="refname">rar_entry_get</span> &mdash; <span class="dc-title">Get entry object from the RAR archive</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-rararchive.getentry-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格 (method):</p>
   <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.rarentry.html" class="type RarEntry">RarEntry</a></span> <span class="methodname"><strong>RarArchive::getEntry</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$entryname</code></span>
    )</div>

  <p class="para rdfs-comment">过程化风格:</p>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.rarentry.html" class="type RarEntry">RarEntry</a></span> <span class="methodname"><strong>rar_entry_get</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.rararchive.html" class="type RarArchive">RarArchive</a></span> <code class="parameter">$rarfile</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$entryname</code></span>
   )</div>

  <p class="para rdfs-comment">
   Get entry object (file or directory) from the RAR archive.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">You can also get entry objects using <span class="methodname"><a href="rararchive.getentries.html" class="methodname">RarArchive::getEntries()</a></span>.</p>
    <p class="para">Note that a RAR archive can have multiple entries with the same name; this method
    will retrieve only the first.</p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-rararchive.getentry-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">rarfile</code></em></dt>

     <dd>

      <p class="para">
       A <span class="type"><a href="class.rararchive.html" class="type RarArchive">RarArchive</a></span> object, opened with <span class="function"><a href="rararchive.open.html" class="function">rar_open()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">entryname</code></em></dt>

     <dd>

      <p class="para">
       Path to the entry within the RAR archive.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">The path must be the same returned by
        <span class="methodname"><a href="rarentry.getname.html" class="methodname">RarEntry::getName()</a></span>.</p>
     </p></blockquote>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-rararchive.getentry-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the matching <span class="type"><a href="class.rarentry.html" class="type RarEntry">RarEntry</a></span> object  或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-rararchive.getentry-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-725">
    <p><strong>Example #1 面向对象风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$rar_arch&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">RarArchive</span><span style="color: #007700">::</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">'solid.rar'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$rar_arch&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;open&nbsp;RAR&nbsp;archive."</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rar_entry&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$rar_arch</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getEntry</span><span style="color: #007700">(</span><span style="color: #DD0000">'tese.txt'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$rar_entry&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;get&nbsp;such&nbsp;entry"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_entry</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$rar_entry</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$rar_arch</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <div class="example-contents"><p>以上例程的输出类似于：</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
RarEntry
RarEntry for file &quot;tese.txt&quot; (23b93a7a)
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-726">
    <p><strong>Example #2 过程化风格</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$rar_arch&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rar_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'solid.rar'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$rar_arch&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;open&nbsp;RAR&nbsp;archive."</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rar_entry&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rar_entry_get</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_arch</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'tese.txt'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$rar_entry&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;get&nbsp;such&nbsp;entry"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_entry</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$rar_entry</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">rar_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$rar_arch</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

   </div>
  </p>
 </div>


  <div class="refsect1 seealso" id="refsect1-rararchive.getentry-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="rararchive.getentries.html" class="methodname" rel="rdfs-seeAlso">RarArchive::getEntries()</a> - Get full list of entries from the RAR archive</span></li>
    <li class="member"><a href="wrappers.rar.html" class="link"><em>rar://</em> wrapper</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="rararchive.getentries.html">RarArchive::getEntries</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="rararchive.isbroken.html">RarArchive::isBroken</a></div>
 <div class="up"><a href="class.rararchive.html">RarArchive</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
